{extend name="public/base"}

{block name="title"}广告列表{/block}

{block name="main"}
<!--  搜索添加   -->
<form action="{:url('/adv')}" class="layui-form layui-form-pane">
  <div class="layui-row">
    <div class="layui-col-md2 ">
      <div class="layui-form-item">
        <label for="position" class="layui-form-label">广告位置：</label>
        <div class="layui-input-block">
          <select name="position" id="position" class="custom-select">
            <option selected value="">选择广告位置：</option>
            <option value="1">顶部图片</option>
            <option value="2">顶部文字</option>
            <option value="3">底部</option>
            <option value="4">浮动</option>
            <option value="5">开奖栏(文字)</option>
            <option value="6">算法栏(文字)</option>
          </select>
        </div>
      </div>
    </div>
    <div class="layui-col-md2 ">
      <div class="layui-form-item" >
        <label for="is_img" class="layui-form-label">是否图片广告：</label>
        <div class="layui-input-block">
          <select name="is_img" id="is_img" class="custom-select">
            <option selected value="">选择是否图片广告：</option>
            <option value="2">否</option>
            <option value="1">是</option>
          </select>
        </div>
      </div>

    </div>
    <div class="layui-col-md3 ">
      <button class="layui-btn layui-btn-normal">搜索</button>
      <a href="{:url('/adv/create')}" class="layui-btn layui-btn-success">添加广告</a>
    </div>
  </div>
</form>

<!--数据列表-->
<table class="layui-table">
  <thead class="bg-light">
  <tr>
    <th class="text-center">ID</th>
    <th class="text-center">广告文本</th>
    <th class="text-center">广告图片</th>
    <th class="text-center">广告链接</th>
    <th class="text-center">广告位置</th>
    <th class="text-center">是否是图片广告</th>
    <th class="text-center">创建时间</th>
    <th class="text-center">操作</th>
  </tr>
  </thead>
  <tbody>
  {assign name="empty" value='<tr><td colspan="7" class="text-center text-muted">没有数据</td></tr>'}
  {volist name="list" id="obj" empty="$empty"}
  <tr>
    <td class="text-center" style="line-height: 80px">{$obj.id}</td>
    <td class="text-center" style="line-height: 80px">{$obj.text|raw}</td>
    <td class="text-center" ><img src="{$obj.img}" style="width: 120px;height: 80px" alt="广告图片"/></td>
    <td class="text-center" style="line-height: 80px"><a href="{$obj.url}"  target="_blank"  alt="{$obj.url}">{$obj.url}</a></td>
    <td class="text-center" style="line-height: 80px">{$obj.position}</td>
    <td class="text-center" style="line-height: 80px">{$obj.is_img}</td>
    <td class="text-center" style="line-height: 80px">{$obj.create_at}</td>
    <td class="text-center" style="line-height: 80px">
      <form action="{:url('/adv/'.$obj.id)}" method="post">
        <input type="hidden" name="_method" value="delete">
        <a href="{:url('/adv/'.$obj.id.'/edit')}" class="layui-btn layui-btn-warning layui-btn-sm">修改</a>
        <button class="layui-btn layui-btn-danger layui-btn-sm btn-delete">删除</button>
      </form>
    </td>
  </tr>
  {/volist}
  </tbody>
</table>
<!--分页-->
{/block}

{block name="js"}
<script type="text/javascript">
  $('.btn-delete').click(() => {
    let flag = confirm('您真的要删除这条数据吗？');
    return flag ? true : false;
  });
  $('[data-toggle="tooltip"]').tooltip();
</script>
{/block}
